#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @Time : 2020/5/16 11:31 上午 
# @Author : JasonFan
# @Version：V 0.1
# @File : forms.py
# @desc :

from django import forms
from django.contrib.auth import  get_user_model

User = get_user_model()

class ResetPasswordForm(forms.ModelForm):
    password2 = forms.CharField(widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ('password',)

    # def __init__(self, *args, **kwargs):
    #     super(ResetPasswordForm, self).__init__(*args, **kwargs)

    def clean_password2(self):
        password = self.cleaned_data.get('password')
        password2 = self.cleaned_data.get('password2')
        if password != password2:
            raise forms.ValidationError('输入的两次密码不一致，请重新输入！')
        return password2